package guava.optionalTest;

import com.google.common.base.Optional;

/**
 * Created by IntelliJ IDEA.
 * User: liuliwei
 * Date: 2017-06-02
 * Time: 下午1:39
 *
 * guava optional 优化返回null的办法
 *
 */
public class OptionalTest {
    public static void main(String[] args) {
        Integer b=null;
        System.out.println(Optional.fromNullable(b).or(3));
        System.out.println(Optional.fromNullable((Integer) null).or(5));
        System.out.println(Optional.absent().get());
    }

}
